resource "google_compute_network_peering_routes_config" "<%= ctx[:primary_resource_id] %>" {
  peering = google_compute_network_peering.peering_primary.name
  network = google_compute_network.network_primary.name

  import_custom_routes = true
  export_custom_routes = true
}

resource "google_compute_network_peering" "peering_primary" {
  name         = "<%= ctx[:vars]['peering_primary_name'] %>"
  network      = google_compute_network.network_primary.id
  peer_network = google_compute_network.network_secondary.id

  import_custom_routes = true
  export_custom_routes = true
}

resource "google_compute_network_peering" "peering_secondary" {
  name         = "<%= ctx[:vars]['peering_secondary_name'] %>"
  network      = google_compute_network.network_secondary.id
  peer_network = google_compute_network.network_primary.id
}

resource "google_compute_network" "network_primary" {
  name                    = "<%= ctx[:vars]['network_primary_name'] %>"
  auto_create_subnetworks = "false"
}

resource "google_compute_network" "network_secondary" {
  name                    = "<%= ctx[:vars]['network_secondary_name'] %>"
  auto_create_subnetworks = "false"
}
